const express = require('express');
const router = express.Router();
const examController = require('../controllers/exam.controller');
const { verifyToken, isSubjectGroupLeader } = require('../middlewares/auth.middleware');

// 获取分页考试数据 - 需要验证token并检查是否为学科组长
router.get('/getExam', verifyToken, isSubjectGroupLeader, examController.getExamList);

// 获取特定学科的所有教师
router.get('/getTeacherOfSubject', 
  verifyToken, 
  isSubjectGroupLeader, 
  examController.getTeachersBySubject
);

// 分配批阅任务
router.post('/saveReviewSettings', 
  verifyToken, 
  isSubjectGroupLeader, 
  examController.saveReviewSettings
);

// 获取某场考试的批阅进度
router.get('/getExamReviewProgress', 
  verifyToken, 
  isSubjectGroupLeader, 
  examController.getExamReviewProgress
);

// 获取考试批阅详情
router.get('/getReviewDetail',
  verifyToken,
  isSubjectGroupLeader,
  examController.getReviewDetail
);

/**
 * @route GET /api/exam/getSubjectiveByExamId
 * @desc 根据考试ID获取本场考试的所有主观题
 * @access 需要token验证
 */
router.get('/getSubjectiveByExamId', verifyToken, examController.getSubjectiveByExamId);

/**
 * @route POST /api/exam/saveSubject
 * @desc 保存主观题评分细则
 * @access 需要token验证
 */
router.post('/saveSubject', verifyToken, examController.saveSubject);

module.exports = router; 